/*
 * @lc app=leetcode.cn id=922 lang=javascript
 *
 * [922] 按奇偶排序数组 II
 */

// @lc code=start
/**
 * @param {number[]} A
 * @return {number[]}
 */
var sortArrayByParityII = function(A) {
    let res=new Array(A.length)
    let even=0,odd=1
    for(let i=0;i<A.length;i++){
        if(A[i]%2==0){res[even]=A[i];even+=2}
        else{
            res[odd]=A[i];odd+=2
        }
    }    
    return res
};
// @lc code=end

